package com.barbeque.mall.service.wx;

import com.barbeque.mall.bean.brand.MarketBrandExample;
import com.barbeque.mall.bean.category.MarketCategory;
import com.barbeque.mall.bean.category.MarketCategoryExample;
import com.barbeque.mall.mapper.MarketCategoryMapper;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 苏东宇
 * @since 2022/07/19 23:13
 */

@Transactional
@Service
public class WxCatalogServiceImpl implements WxCatalogService {

    @Autowired
    MarketCategoryMapper marketCategoryMapper;
    /**
     * 根据id查询类别
     * @param id
     * @return
     */
    @Override
    public MarketCategory getCatalogById(Integer id) {

        MarketCategory marketCategory = marketCategoryMapper.selectByPrimaryKey(id);

        return marketCategory;
    }

    @Override
    public List<MarketCategory> getCatalogByPid(Integer pid) {
        MarketCategoryExample marketCategoryExample = new MarketCategoryExample();
        MarketCategoryExample.Criteria criteria = marketCategoryExample.createCriteria();
        criteria.andPidEqualTo(pid);
        criteria.andDeletedEqualTo(false);
        List<MarketCategory> marketCategories = marketCategoryMapper.selectByExample(marketCategoryExample);



        return marketCategories;
    }

    @Override
    public Integer[] getIdsByPid(int id) {
        return marketCategoryMapper.selectIdsByPid(id);
    }
}
